package com.tangyuan.common.util;

import org.springframework.stereotype.Component;


@Component
public class DurationUtil {

    public static String calculateDuration(Long currentTime,Long createTime){
        long time = (currentTime - createTime) / 1000;
        if(time == 0){
            return "00:00:00";
        }
        if(time < 0){
            return "";
        }
        String hour = (time / 60 / 60) < 10 ? "0"+(time / 60 / 60 ) : String.valueOf(time / 60 / 60 );
        String minute = (time / 60 % 60) < 10 ? "0"+(time / 60 % 60) : String.valueOf(time / 60 % 60);
        String second = (time % 60) < 10 ? "0"+(time % 60) : String.valueOf(time % 60);
        return hour + ":" + minute + ":" + second;
    }

}
